const app = getApp()
import {
  HomeIndex
} from 'index-modal.js';
import {
  Config
} from '../../../utils/config.js';
var Function = require("../../../utils/function.js");
var index = new HomeIndex(); //实例化 首页 对象;

Page({

  /**
   * 页面的初始数据
   */
  data: {
    heicli:0,
    widcli:0,
    price:0,
    state:0,
    content:""
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

    // this.setData({
    //     heicli: app.globalData.windowHeight+'px',
    //     widcli:app.globalData.windowWidth+'px'
    // });
    this._getback()
  },

  // 支付
  getPayInfo:function(){
    let that=this;
    let data={
      uid: wx.getStorageSync('members').id,
      type:2
    }
    index.wePayment(data,(res)=>{
      if (res.code == 200) {
        wx.requestPayment({
          'timeStamp': res.data.timeStamp.toString(),
          'nonceStr': res.data.nonceStr,
          'package': res.data.package,
          'signType': res.data.signType,
          'paySign': res.data.paySign,
          success: function (ress) {
            wx.switchTab({
              url: '/pages/my/mine/mine',
            })
          },
          fail: function (err) {
            that.delete_bang();
          }
        })
      } else {
        // Function.layer(res.msg)
      }
    })
  },
  delete_bang:function(){
    let data={
      uid: wx.getStorageSync('members').id
    }
    index.delete_bang(data,(res)=>{

    })
  },

  _getback(){
    let that =this;
    let data ={
      id:wx.getStorageSync('members')['id']
    }
    index.getback(data,(res)=>{
      if(res.code == 200){
         that.setData({
           content: res.count.content,
           price:res.count.price,
           state: res.data.state
         })
      }
    })
  },
  //
  config:function(){
    let that=this;
    index.config((res)=>{
      if(res.code==200){
        that.setData({
          bang_zhe: res.data.bang_zhe,
          bang: res.data.bang
        })
      }
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.config();
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})